<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="员工姓名" v-model="e.name">
    <input type="text" placeholder="员工工资" v-model="e.sal">
    <input type="text" placeholder="员工工作" v-model="e.job">

    <input type="button" value="添加员工" @click="add()">
    <table border=" ">
        <caption>员工列表</caption>
        <tr>
            <th>姓名</th>
            <th>工资</th>
            <th>工作</th>
            <th>操作</th>
        </tr>
        <tr v-for="(emp,i) in arr">
            <td>{{i+1}}</td>
            <td>{{emp.name}}</td>
            <td>{{emp.sal}}</td>
            <td>{{emp.job}}</td>
            <td><input type="button" value="删除" @click="del(i)"></td>

        </tr>
    </table>
</div>

<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">

</script>
<script>
    let v=new Vue({
        el:"body>div",
        data:{
            e:{name:"",sal:"",job:""},
            arr:[{name:"张三",sal:"3000",job:"销售"},
                {name:"李四",sal:"4000",job:"人事"}]
        },
        methods:{
            add(){
                //创建一个新对象 数据来自于双向绑定的员工对象e
                v.arr.push({name:v.e.name,sal:v.e.sal,job:v.e.job});
            },
            del(i){
                v.arr.splice(i,1);
            }

        }
    })

</script>

</body>
</html>